package org.edu.modules.center.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.edu.common.api.vo.Result;
import org.edu.common.aspect.annotation.AutoLog;
import org.edu.common.system.base.controller.BaseController;
import org.edu.common.system.query.QueryGenerator;
import org.edu.modules.center.entity.VeAddonsStar;
import org.edu.modules.center.service.IVeAddonsStarService;
import org.edu.modules.center.vo.VeAddonsStarVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags={"星级评价表"})
@RestController
@RequestMapping({"/center/veAddonsStar"})
public class VeAddonsStarController
        extends BaseController<VeAddonsStar, IVeAddonsStarService>
{
    private static final Logger log = LoggerFactory.getLogger(VeAddonsStarController.class);
    @Autowired
    private IVeAddonsStarService veAddonsStarService;

    @AutoLog("星级评价表-全部评价分页查询")
    @ApiOperation(value="全部评价分页查询", notes="星级评价表-全部评价分页查询")
    @PostMapping({"/list"})
    public Result<?> allList(VeAddonsStarVo veAddonsStarVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req)
    {
        VeAddonsStar veAddonsStar = new VeAddonsStar();
        BeanUtils.copyProperties(veAddonsStarVo, veAddonsStar);
        Integer tcid = Integer.valueOf(0);Integer objectid = Integer.valueOf(0);
        tcid = veAddonsStarVo.getTcid();
        objectid = tcid;
        veAddonsStar.setObjectid(tcid);
        QueryWrapper<VeAddonsStar> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsStar, req.getParameterMap());
        Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
        queryWrapper.setEntity(veAddonsStar);
        IPage<Map<String, Object>> pageList = this.veAddonsStarService.aPageMaps(page, queryWrapper);
        return Result.OK(pageList);
    }

    @AutoLog("星级评价表-好评分页查询")
    @ApiOperation(value="好评分页查询", notes="星级评价表-好评分页查询")
    @PostMapping({"/goodList"})
    public Result<?> queryGoodPageList(VeAddonsStarVo veAddonsStarVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req)
    {
        VeAddonsStar veAddonsStar = new VeAddonsStar();
        BeanUtils.copyProperties(veAddonsStarVo, veAddonsStar);
        Integer tcid = Integer.valueOf(0);Integer objectid = Integer.valueOf(0);
        tcid = veAddonsStarVo.getTcid();
        objectid = tcid;
        veAddonsStar.setObjectid(tcid);
        QueryWrapper<VeAddonsStar> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsStar, req.getParameterMap());
        Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
        queryWrapper.setEntity(veAddonsStar);
        IPage<Map<String, Object>> pageList = this.veAddonsStarService.gPageMaps(page, queryWrapper);
        return Result.OK(pageList);
    }

    @AutoLog("星级评价表-中评分页查询")
    @ApiOperation(value="中评分页查询", notes="星级评价表-中评分页查询")
    @PostMapping({"/regularList"})
    public Result<?> queryRegularPageList(VeAddonsStarVo veAddonsStarVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req)
    {
        VeAddonsStar veAddonsStar = new VeAddonsStar();
        BeanUtils.copyProperties(veAddonsStarVo, veAddonsStar);
        Integer tcid = Integer.valueOf(0);Integer objectid = Integer.valueOf(0);
        tcid = veAddonsStarVo.getTcid();
        objectid = tcid;
        veAddonsStar.setObjectid(tcid);
        QueryWrapper<VeAddonsStar> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsStar, req.getParameterMap());
        Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
        queryWrapper.setEntity(veAddonsStar);
        IPage<Map<String, Object>> pageList = this.veAddonsStarService.rPageMaps(page, queryWrapper);
        return Result.OK(pageList);
    }

    @AutoLog("星级评价表-差评分页查询")
    @ApiOperation(value="差评分页查询", notes="星级评价表-差评分页查询")
    @PostMapping({"/poorList"})
    public Result<?> queryPoorPageList(VeAddonsStarVo veAddonsStarVo, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req)
    {
        VeAddonsStar veAddonsStar = new VeAddonsStar();
        BeanUtils.copyProperties(veAddonsStarVo, veAddonsStar);
        Integer tcid = Integer.valueOf(0);Integer objectid = Integer.valueOf(0);
        tcid = veAddonsStarVo.getTcid();
        objectid = tcid;
        veAddonsStar.setObjectid(tcid);
        QueryWrapper<VeAddonsStar> queryWrapper = QueryGenerator.initQueryWrapper(veAddonsStar, req.getParameterMap());
        Page<Map<String, Object>> page = new Page(pageNo.intValue(), pageSize.intValue());
        queryWrapper.setEntity(veAddonsStar);
        IPage<Map<String, Object>> pageList = this.veAddonsStarService.pPageMaps(page, queryWrapper);
        return Result.OK(pageList);
    }

    @AutoLog("星级评价表-通过id查询")
    @ApiOperation(value="通过id查询", notes="星级评价表-通过id查询")
    @PostMapping({"/queryById"})
    public Result<?> queryById(@RequestParam(name="id", required=true) String id)
    {
        VeAddonsStar veAddonsStar = (VeAddonsStar)this.veAddonsStarService.getById(id);
        if (veAddonsStar == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(veAddonsStar);
    }

    @AutoLog("星级评价表-新增信息")
    @ApiOperation(value="新增信息", notes="星级评价表-新增信息")
    @PostMapping({"/add"})
    public Result<?> add(@RequestBody VeAddonsStar veAddonsStar)
    {
        this.veAddonsStarService.save(veAddonsStar);
        return Result.OK("添加成功！");
    }

    @AutoLog("星级评价表-修改信息")
    @ApiOperation(value="修改信息", notes="星级评价表-修改信息")
    @PostMapping({"/edit"})
    public Result<?> edit(@RequestBody VeAddonsStar veAddonsStar)
    {
        this.veAddonsStarService.updateById(veAddonsStar);
        return Result.OK("编辑成功!");
    }

    @AutoLog("星级评价表-通过id删除")
    @ApiOperation(value="通过id删除", notes="星级评价表-通过id删除")
    @PostMapping({"/delete"})
    public Result<?> delete(@RequestParam(name="id", required=true) String id)
    {
        this.veAddonsStarService.removeById(id);
        return Result.OK("删除成功!");
    }

    @AutoLog("星级评价表-批量删除")
    @ApiOperation(value="批量删除", notes="星级评价表-批量删除")
    @PostMapping({"/deleteBatch"})
    public Result<?> deleteBatch(@RequestParam(name="ids", required=true) String ids)
    {
        this.veAddonsStarService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
}
